package cool.webstudy.admin.utils;

import java.util.Calendar;
import java.util.Date;

/**
 * @author 莫振双
 * @date 2025/3/19 22:24
 * @description: 时间工具类
 */
public class TimeUtil {
    /**
     * @param date 要比较的时间
     * @return boolean 是否是今天
     * @description: 判断所传日期时间是否是今天
     */
    public static boolean isToday(Date date) {
        Calendar cal1 = Calendar.getInstance();
        cal1.setTime(date);

        Calendar cal2 = Calendar.getInstance();
        cal2.setTime(new Date());

        return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
                cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH) &&
                cal1.get(Calendar.DAY_OF_MONTH) == cal2.get(Calendar.DAY_OF_MONTH);
    }
}
